package com.first.teacher.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.first.common.pojo.EduTeacher;
import com.first.common.pojo.TbCheckTeacher;
import com.first.common.pojo.TbMember;
import com.first.teacher.mapper.Membermapper;
import com.first.teacher.mapper.TbCheckTeacherMapper;
import com.first.teacher.mapper.TeacherMapper;
import com.first.teacher.service.TbCheckTeacherService;

import com.first.teacher.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @program: first-project
 * @description:
 * @author: 马英贤
 * @create: 2023-05-29 17:28
 **/
@Service
public class TbCheckTeacherServiceImpl implements TbCheckTeacherService {

    @Autowired
    private TbCheckTeacherMapper tbCheckTeacherMapper;

    @Autowired
    private Membermapper membermapper;

    @Autowired
    private TeacherMapper teacherMapper;


    @Override
    public int modifyTeacher(TbCheckTeacher tbCheckTeacher) {
        System.out.println(tbCheckTeacher);
        if (tbCheckTeacher.getCheckStatus().equals("1") || tbCheckTeacher.getCheckStatus().equals("0")){
            tbCheckTeacher.setCheckTime(LocalDateTime.now());
            tbCheckTeacherMapper.updateById(tbCheckTeacher);
            if (tbCheckTeacher.getCheckStatus().equals("0")){
                teacherMapper.deleteById(tbCheckTeacher.getTeacherId());
                tbCheckTeacherMapper.deleteById(tbCheckTeacher.getTeacherCheckId());
                return 0;
            }
            String teacher_id = tbCheckTeacher.getTeacherId();
            membermapper.updateCheckStatus(teacher_id);
        }
        return 1;
    }
}
